JBoss Community Archive (Read Only)

GateIn Portal 3.5

Custom Navigation and Pages

This section mentions code from Portal Extension Example from the GateIn Portal Quickstarts collection.

In Portal Extension quickstart, we have added a couple of navigation nodes and pages to the ones available in the default GateIn Portal installation.

portal-configuration.xml

In Portal Extension quickstart, this configuration file is located in war/src/main/webapp/WEB-INF/conf/sample-ext/portal directory. It is the starting point of the navigation customization. We will not say more about this file here as there is usually no need to change it. Please refer to Portal Navigation Configuration section of GateIn Portal Reference Guide for more information.

Three kinds of Navigation

Rather than using too many words to explain what and why, let us look at the following image:

images/author/download/attachments/55379565/Kinds of Navigation.png
Kinds of Navigation

Adding a Navigation Node to a Site Navigation

Let us have a look at war/src/main/webapp/WEB-INF/conf/sample-ext/portal/portal/classic/navigation.xml. Note that in this path, classic is the name of the site the navigation of which we are which we want to define.

Site-wide navigation.xml
19. <node-navigation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20.     xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_3 http://www.gatein.org/xml/ns/gatein_objects_1_3" xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_3">
21.     <!-- Priority has no significance in site navigations. But it is required. See GTNPORTAL-2751 -->
22.     <priority>1</priority>
23.     
24.     <!-- 
25.         In this file, we are adding a navigation node to the navigation of the site called "classic". 
26.         The site-wide navigation is used e.g. in NavigationPortlet. 
27.         Visibility of navigation nodes depends on <access-permissions> set in the sibling pages.xml file.
28.         See also portal.configuration section of the file ../../portal-configuration.xml. 
29.     -->
30.     <page-nodes>
31.         <node>
32.             <name>page-just-added</name>
33.             <!-- 
34.                 #{portal.extension.justAddedPage} is  place holder for an internationalized string.
35.                 See WEB-INF/classes/locale/navigation/portal/classic_en.properties
36.             -->
37.             <label>#{portal.extension.justAddedPage}</label>

In this file, we have added page-just-added navigation node into the portal navigation. It can be seen in the navigation bar.

images/author/download/attachments/55379565/navigation-bar.png

The page-just-added navigation node refers to portal::classic::justAddedPage which we define in pages.xml file located in the same directory as the above navigation.xml.

Site-wide pages.xml
19. <page-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_3 http://www.gatein.org/xml/ns/gatein_objects_1_3"
20.     xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_3">
21.     <page>
22.         <name>justAddedPage</name>
23.         <title>Page Just Added</title>
24.         <!-- This page and any navigation nodes refering to it will be visible to all visitors (signed in or anonymous). -->
25.         <access-permissions>Everyone</access-permissions>
26.         <edit-permission>*:/platform/administrators</edit-permission>
27.         <portlet-application>
28.             <portlet>
29.                 <application-ref>gatein-portal-extension</application-ref>
30.                 <portlet-ref>JustAddedPortlet</portlet-ref>
31.             </portlet>
32.             <title>Just Added Portlet</title>
33.             <access-permissions>Everyone</access-permissions>
34.             <show-info-bar>false</show-info-bar>
35.             <show-application-state>false</show-application-state>
36.             <show-application-mode>false</show-application-mode>
37.         </portlet-application>
38.     </page>
39. </page-set>

Note that page-just-added navigation node and the related pages are visible to all portal visitors (signed in or anonymous) due to <access-permissions> set to Everyone in the above file.

Adding a Navigation Node to a Group Navigation

To add a new navigation node visible to the members of /platform/administrators group we need to create a navigation.xml file located in war/src/main/webapp/WEB-INF/conf/sample-ext/portal/group/platform/administrators/navigation.xml. Note that the name of the user group /platform/administrators is a part of the path.

navigation.xml of /platform/administrators group
19. <node-navigation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20.     xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_3 http://www.gatein.org/xml/ns/gatein_objects_1_3" xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_3">
21.     <!-- Priority is currently ignored for importMode merge. But it is required. See GTNPORTAL-2751 -->
22.     <priority>1</priority>
23. 
24.     <page-nodes>
25.         <node>
26.             <name>admins-sitemap</name>
27.             <!-- 
28.                 #{platform.administrators.adminsSitemap} is  place holder for an internationalized string.
29.                 See WEB-INF/classes/locale/navigation/group/platform/administrators_en.properties
30.             -->
31.             <label>#{platform.administrators.adminsSitemap}</label>
32.             <page-reference>group::/platform/administrators::adminsSitemap</page-reference>
33.         </node>
34.     </page-nodes>
35. </node-navigation>

The navigation node admins-sitemap refers to adminsSitemap page defined in the sibling pages.xml file:

pages.xml of /platform/administrators group
19.     xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_3">
20.     <!-- 
21.         adminsSitemap page contains just SiteMapPortlet. There is nothing special about it. 
22.         It is here just to demonstrate the adding of nodes to group navigation in the sibling 
23.         navigation.xml file.
24.     -->
25.     <page>
26.         <name>adminsSitemap</name>
27.         <title>Admins' Sitemap</title>
28.         <access-permissions>*:/platform/administrators</access-permissions>
29.         <edit-permission>*:/platform/administrators</edit-permission>
30.         <portlet-application>
31.             <portlet>
32.                 <application-ref>web</application-ref>
33.                 <portlet-ref>SiteMapPortlet</portlet-ref>
34.             </portlet>
35.             <title>Sitemap</title>
36.             <access-permissions>*:/platform/administrators</access-permissions>
37.             <show-info-bar>false</show-info-bar>
38.         </portlet-application>
39.     </page>
40. </page-set>

Adding a Navigation Node to a User Navigation

To add a new navigation node visible to a particular user, say root we need to create a navigation.xml file located in war/src/main/webapp/WEB-INF/conf/sample-ext/portal/user/root/navigation.xml. Note that the name of the user root is a part of the path.

navigation.xml of user root
19. <node-navigation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20.     xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_3 http://www.gatein.org/xml/ns/gatein_objects_1_3" xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_3">
21.     <!-- Priority has no significance in user navigations. But it is required. See GTNPORTAL-2751 -->
22.     <priority>1</priority>
23. 
24.     <page-nodes>
25.         <node>
26.             <name>roots-extra-dashboard</name>
27.             <label>#{user.root.RootsExtraDashboard}</label>
28.             <page-reference>user::root::roots-dashboard</page-reference>
29.         </node>
30.     </page-nodes>
31. </node-navigation>

The navigation node roots-extra-dashboard refers to roots-dashboard page defined in the sibling pages.xml file:

pages.xml of user root
19. <page-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_3 http://www.gatein.org/xml/ns/gatein_objects_1_3"
20.     xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_3">
21.     <!-- 
22.         roots-dashboard page contains just DashboardPortlet. There is nothing special about it. 
23.         It is here just to demonstrate the adding of nodes to user navigation in the sibling 
24.         navigation.xml file.
25.     -->
26.     <page>
27.         <name>roots-dashboard</name>
28.         <title>Root's Extra Dashboard</title>
29.         <access-permissions>*:/platform/users</access-permissions>
30.         <edit-permission>*:/platform/administrators</edit-permission>
31.         <portlet-application>
32.             <portlet>
33.                 <application-ref>dashboard</application-ref>
34.                 <portlet-ref>DashboardPortlet</portlet-ref>
35.             </portlet>
36.             <title>Root's Extra Dashboard</title>
37.             <access-permissions>*:/platform/users</access-permissions>
38.             <show-info-bar>false</show-info-bar>
39.         </portlet-application>
40.     </page>
41. </page-set>
42. 

Internationalization of Navigation Nodes

As you can see in the above navigation.xml files the labels of navigation nodes can be internationalized. The files containing translation resources live under war/src/main/webapp/WEB-INF/classes/locale/navigation. The directory layout is similar to the one used for navigation.xml and pages.xml files:

Note that the navigation resource bundles also need to be named in init.resources parameter of BaseResourceBundlePlugin in war/src/main/webapp/WEB-INF/conf/sample-ext/common/common-configuration.xml:

common-configuration.xml containing declarations of navigation resource bundles
19. <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20.     xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd" xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
21.     <external-component-plugins>
22.         <!-- The full qualified name of the ResourceBundleService -->
23.         <target-component>org.exoplatform.services.resources.ResourceBundleService</target-component>
24.         <component-plugin>
25.             <!-- The name of the plugin -->
26.             <name>Sample ResourceBundle Plugin</name>
27.             <!-- The name of the method to call on the ResourceBundleService in order to register the ResourceBundles -->
28.             <set-method>addResourceBundle</set-method>
29.             <!-- The full qualified name of the BaseResourceBundlePlugin -->
30.             <type>org.exoplatform.services.resources.impl.BaseResourceBundlePlugin</type>
31.             <init-params>
32.                 <values-param>
33.                     <name>init.resources</name>
34.                     <description>Initiate the following resources during the first launch.</description>
35.                     <value>locale.portal.extension</value>
36.                     <value>locale.navigation.user.root</value>
37.                     <!-- 
38.                         Note that we actually do not need to name locale.navigation.portal.classic and 
39.                         locale.navigation.group.platform.administrators here as they are in init.resources 
40.                         of the default GateIn installation. But it makes no harm to include them once again here.
41.                     -->
42.                     <value>locale.navigation.portal.classic</value>
43.                     <value>locale.navigation.group.platform.administrators</value>
44.                 </values-param>
45.                 <values-param>
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 12:47:29 UTC, last content change 2012-12-06 13:46:29 UTC.